import { HooksDemos } from "@/lib/@docs/demos/src";
import { Layout } from "@/layout";
import { MDX_DATA } from "@/mdx";

export default Layout(MDX_DATA.usePrevious);

## Usage

`use-previous` stores the previous value of a state in a ref.
It returns `undefined` on initial render and the previous value of a state after rerender:

<Demo data={HooksDemos.usePreviousUsage} />

## Definition

```tsx
function usePrevious<T>(value: T): T | undefined;
```
